home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 October / CMCD1004.ISO / Software / Freeware / Utilitare / DesktopSidebar / Plugins / NotesEditor.DSPACKAGE / Source Code / EditNote.cs < prev    next >
Encoding:
Text File  |  2004-07-09  |  11.6 KB  |  370 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Resources;
  7. using DesktopSidebar;
  8.  
  9. namespace NotesEditor
  10. {
  11.     /// <summary>
  12.     /// Summary description for NoteDlg.
  13.     /// </summary>
  14.     public class EditNote : System.Windows.Forms.Form
  15.     {
  16.         private System.Windows.Forms.Button button3;
  17.         private System.Windows.Forms.MenuItem menuItem4;
  18.         private System.Windows.Forms.Button button1;
  19.         private System.Windows.Forms.Label label1;
  20.         private System.Windows.Forms.TextBox txtNote;
  21.         private System.Windows.Forms.Button btnCancel;
  22.         private System.Windows.Forms.ContextMenu contextMenu1;
  23.         private System.Windows.Forms.ComboBox comboBox1;
  24.         private System.Windows.Forms.Button button2;
  25.         private System.Windows.Forms.MenuItem menuItem1;
  26.         private System.Windows.Forms.MenuItem menuItem3;
  27.         private System.Windows.Forms.Button btnOK;
  28.         private System.Windows.Forms.MenuItem menuItem2;
  29.         private ISidebar m_sidebar;
  30.         private bool sdn2;
  31.         private string ic;
  32.         /// <summary>
  33.         /// Required designer variable.
  34.         /// </summary>
  35.         private System.ComponentModel.Container components = null;
  36.  
  37.         public EditNote(ISidebar sidebar)
  38.         {
  39.             //
  40.             // Required for Windows Form Designer support
  41.             //
  42.         m_sidebar = sidebar;
  43.         InitializeComponent();
  44.     sidebar.GetTranslator().TranslateDialog2(new DialogTranslator(this),"NotesEditor.EditNote");
  45.          
  46.         }
  47.         
  48.          public string icl
  49.         {
  50.             get
  51.             {
  52.             return ic;
  53.             }
  54.         }
  55.         
  56.           public string GetNote()
  57.         {
  58.             return txtNote.Text;
  59.         }
  60.  
  61.         public void SetNote(string sNote)
  62.         {
  63.             txtNote.Text = sNote;
  64.         }
  65.         
  66.         public void setcolor(string icolor)
  67.         { 
  68.                int ind = this.comboBox1.Items.IndexOf(icolor);
  69.             this.comboBox1.SelectedIndex = ind;
  70.             ic = this.comboBox1.SelectedItem.ToString();
  71.         }
  72.         
  73.         
  74.         public void setsdn(bool sdn)
  75.         {
  76.             this.sdn2=sdn;
  77.         }
  78.     
  79.         /// <summary>
  80.         /// Clean up any resources being used.
  81.         /// </summary>
  82.         protected override void Dispose( bool disposing )
  83.         {
  84.             if( disposing )
  85.             {
  86.                 if(components != null)
  87.                 {
  88.                     components.Dispose();
  89.                 }
  90.             }
  91.             base.Dispose( disposing );
  92.         }
  93.  
  94.         #region Windows Form Designer generated code
  95.         /// <summary>
  96.         /// Required method for Designer support - do not modify
  97.         /// the contents of this method with the code editor.
  98.         /// </summary>
  99.         private void InitializeComponent() {
  100.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(EditNote));
  101.             this.menuItem2 = new System.Windows.Forms.MenuItem();
  102.             this.btnOK = new System.Windows.Forms.Button();
  103.             this.menuItem3 = new System.Windows.Forms.MenuItem();
  104.             this.menuItem1 = new System.Windows.Forms.MenuItem();
  105.             this.button2 = new System.Windows.Forms.Button();
  106.             this.comboBox1 = new System.Windows.Forms.ComboBox();
  107.             this.contextMenu1 = new System.Windows.Forms.ContextMenu();
  108.             this.btnCancel = new System.Windows.Forms.Button();
  109.             this.txtNote = new System.Windows.Forms.TextBox();
  110.             this.label1 = new System.Windows.Forms.Label();
  111.             this.button1 = new System.Windows.Forms.Button();
  112.             this.menuItem4 = new System.Windows.Forms.MenuItem();
  113.             this.button3 = new System.Windows.Forms.Button();
  114.             this.SuspendLayout();
  115.             // 
  116.             // menuItem2
  117.             // 
  118.             this.menuItem2.Index = 1;
  119.             this.menuItem2.Text = m_sidebar.GetTranslator().TranslateCommand("menuItem2");
  120.             this.menuItem2.Click += new System.EventHandler(this.menu2Ic);
  121.             // 
  122.             // btnOK
  123.             // 
  124.             this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
  125.             this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
  126.             this.btnOK.Location = new System.Drawing.Point(288, 176);
  127.             this.btnOK.Name = "btnOK";
  128.             this.btnOK.TabIndex = 1;
  129.             this.btnOK.Text = "OK";
  130.             // 
  131.             // menuItem3
  132.             // 
  133.             this.menuItem3.Index = 2;
  134.             this.menuItem3.Text = m_sidebar.GetTranslator().TranslateCommand("menuItem3");
  135.             this.menuItem3.Click += new System.EventHandler(this.menu3Ic);
  136.             // 
  137.             // menuItem1
  138.             // 
  139.             this.menuItem1.Index = 0;
  140.             this.menuItem1.Text =  m_sidebar.GetTranslator().TranslateCommand("menuItem1");
  141.             this.menuItem1.Click += new System.EventHandler(this.menu1Ic);
  142.             // 
  143.             // button2
  144.             // 
  145.             this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
  146.             this.button2.Location = new System.Drawing.Point(8, 176);
  147.             this.button2.Name = "button2";
  148.             this.button2.TabIndex = 7;
  149.             this.button2.Text = "Delete";
  150.             this.button2.Click += new System.EventHandler(this.Button2Click);
  151.             // 
  152.             // comboBox1
  153.             // 
  154.                 this.comboBox1.Items.AddRange(new object[] {
  155.                         m_sidebar.GetTranslator().TranslateCommand("Black"),
  156.                         m_sidebar.GetTranslator().TranslateCommand("Red"),
  157.                         m_sidebar.GetTranslator().TranslateCommand("Green"),
  158.                         m_sidebar.GetTranslator().TranslateCommand("Yellow"),
  159.                         m_sidebar.GetTranslator().TranslateCommand("Blue"),
  160.                         m_sidebar.GetTranslator().TranslateCommand("Purple"),
  161.                         m_sidebar.GetTranslator().TranslateCommand("Orange"),
  162.                         m_sidebar.GetTranslator().TranslateCommand("White"),
  163.                         m_sidebar.GetTranslator().TranslateCommand("Turquoise")});
  164.             this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  165.             this.comboBox1.Location = new System.Drawing.Point(96, 184);
  166.             this.comboBox1.Name = "comboBox1";
  167.             this.comboBox1.Size = new System.Drawing.Size(104, 21);
  168.             this.comboBox1.TabIndex = 5;
  169.             this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.ComboBox1SelectedIndexChanged);
  170.             // 
  171.             // contextMenu1
  172.             // 
  173.             this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  174.                         this.menuItem1,
  175.                         this.menuItem2,
  176.                         this.menuItem3,
  177.                         this.menuItem4});
  178.             // 
  179.             // btnCancel
  180.             // 
  181.             this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  182.             this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
  183.             this.btnCancel.Location = new System.Drawing.Point(368, 176);
  184.             this.btnCancel.Name = "btnCancel";
  185.             this.btnCancel.TabIndex = 2;
  186.             this.btnCancel.Text = "Cancel";
  187.             // 
  188.             // txtNote
  189.             // 
  190.             this.txtNote.Location = new System.Drawing.Point(8, 8);
  191.             this.txtNote.Multiline = true;
  192.             this.txtNote.Name = "txtNote";
  193.             this.txtNote.Size = new System.Drawing.Size(440, 160);
  194.             this.txtNote.TabIndex = 0;
  195.             this.txtNote.Text = "";
  196.             this.txtNote.WordWrap = false;
  197.             this.txtNote.ScrollBars = System.Windows.Forms.ScrollBars.Both;
  198.             // 
  199.             // label1
  200.             // 
  201.             this.label1.Location = new System.Drawing.Point(120, 168);
  202.             this.label1.Name = "label1";
  203.             this.label1.Size = new System.Drawing.Size(64, 16);
  204.             this.label1.TabIndex = 6;
  205.             this.label1.Text = "Text Color:";
  206.             // 
  207.             // button1
  208.             // 
  209.             this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
  210.             this.button1.Location = new System.Drawing.Point(208, 176);
  211.             this.button1.Name = "button1";
  212.             this.button1.TabIndex = 5;
  213.             this.button1.Text = "Options";
  214.             this.button1.Click += new System.EventHandler(this.Button1Click);
  215.             // 
  216.             // menuItem4
  217.             // 
  218.             this.menuItem4.Index = 3;
  219.             this.menuItem4.Text =  m_sidebar.GetTranslator().TranslateCommand("menuItem4");
  220.             this.menuItem4.Click += new System.EventHandler(this.menu4Ic);
  221.             // 
  222.             // button3
  223.             // 
  224.             this.button3.Location = new System.Drawing.Point(0, 0);
  225.             this.button3.Name = "button3";
  226.             this.button3.TabIndex = 0;
  227.             // 
  228.             // EditNote
  229.             // 
  230.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  231.             this.ClientSize = new System.Drawing.Size(458, 208);
  232.             this.Controls.Add(this.button2);
  233.             this.Controls.Add(this.label1);
  234.             this.Controls.Add(this.comboBox1);
  235.             this.Controls.Add(this.button1);
  236.             this.Controls.Add(this.btnCancel);
  237.             this.Controls.Add(this.btnOK);
  238.             this.Controls.Add(this.txtNote);
  239.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  240.             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  241.             this.Name = "EditNote";
  242.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  243.             this.Text = "Edit Note";
  244.             this.ResumeLayout(false);
  245.         }
  246.         #endregion
  247.         
  248.     
  249.     public void Button2Click(object sender,EventArgs e)
  250.     {
  251.         if(sdn2==true)
  252.         {
  253.         string caption = m_sidebar.GetTranslator().Msg("enc");
  254.            string question = m_sidebar.GetTranslator().Msg("dn");
  255.         if (MessageBox.Show(question, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  256.         {
  257.         this.DialogResult = DialogResult.Abort;
  258.         this.Close();
  259.         }
  260.         }
  261.         else
  262.         {
  263.         this.DialogResult = DialogResult.Abort;
  264.         this.Close();
  265.         }
  266.     }
  267.  
  268.  
  269. void ComboBox1SelectedIndexChanged(object sender, System.EventArgs e)
  270. {
  271.     ic = this.comboBox1.SelectedItem.ToString();
  272. }
  273.  
  274.  
  275.  
  276.  
  277.     void Button1Click(object sender, System.EventArgs e)
  278.     {
  279.         contextMenu1.Show(this, button1.Location);
  280.     }
  281.     
  282.     void menu1Ic(object sender, System.EventArgs e)
  283.     {
  284.         string hour = DateTime.Now.Hour.ToString();
  285.         if(hour.Length<2)
  286.         {
  287.             hour=String.Concat("0",DateTime.Now.Hour.ToString());
  288.         }
  289.         string minute = DateTime.Now.Minute.ToString();
  290.         if(minute.Length<2)
  291.         {
  292.             minute=String.Concat("0",DateTime.Now.Minute.ToString());
  293.         }
  294.         string second = DateTime.Now.Second.ToString();
  295.         if(second.Length<2)
  296.         {
  297.             second=String.Concat("0",DateTime.Now.Second.ToString());
  298.         }
  299.         int temper = txtNote.SelectionStart;
  300.         string temper2 = txtNote.Text;
  301.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  302.         string temper4 = temper2.Remove(0,temper);
  303.         string temper5 = temper3 + hour+":"+minute+":"+second + temper4;
  304.         this.txtNote.Text = temper5;
  305.     }
  306.     void menu2Ic(object sender, System.EventArgs e)
  307.     {
  308.         string hour = DateTime.Now.Hour.ToString();
  309.         if(hour.Length<2)
  310.         {
  311.             hour=String.Concat("0",DateTime.Now.Hour.ToString());
  312.         }
  313.         string minute = DateTime.Now.Minute.ToString();
  314.         if(minute.Length<2)
  315.         {
  316.             minute=String.Concat("0",DateTime.Now.Minute.ToString());
  317.         }
  318.         int temper = txtNote.SelectionStart;
  319.         string temper2 = txtNote.Text;
  320.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  321.         string temper4 = temper2.Remove(0,temper);
  322.         string temper5 = temper3 + hour+":"+minute + temper4;
  323.     this.txtNote.Text = temper5 ;
  324.     }
  325.     void menu3Ic(object sender, System.EventArgs e)
  326.     {
  327.         string day = DateTime.Now.Day.ToString();
  328.         if(day.Length<2)
  329.         {
  330.             day=String.Concat("0",DateTime.Now.Day.ToString());
  331.         }
  332.         string month = DateTime.Now.Month.ToString();
  333.         if(month.Length<2)
  334.         {
  335.             month=String.Concat("0",DateTime.Now.Month.ToString());
  336.         }
  337.     int temper = txtNote.SelectionStart;
  338.         string temper2 = txtNote.Text;
  339.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  340.         string temper4 = temper2.Remove(0,temper);
  341.         string temper5 = temper3 + day+"/"+month+"/"+DateTime.Now.Year + temper4;
  342.         this.txtNote.Text = temper5;
  343.     }
  344.     void menu4Ic(object sender, System.EventArgs e)
  345.     {
  346.         string day = DateTime.Now.Day.ToString();
  347.         if(day.Length<2)
  348.         {
  349.             day=String.Concat("0",DateTime.Now.Day.ToString());
  350.         }
  351.         string month = DateTime.Now.Month.ToString();
  352.         if(month.Length<2)
  353.         {
  354.             month=String.Concat("0",DateTime.Now.Month.ToString());
  355.         }
  356.         int temper = txtNote.SelectionStart;
  357.         string temper2 = txtNote.Text;
  358.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  359.         string temper4 = temper2.Remove(0,temper);
  360.         string temper5 = temper3 + month+"/"+day+"/"+DateTime.Now.Year + temper4;
  361.         this.txtNote.Text = temper5;
  362.     }
  363.     
  364.  
  365.  
  366.     }
  367.     
  368.     }
  369.  
  370.